
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>sintef &#8212; Texas A&amp;M Oil spill / Outfall Calculator 2.1.0 documentation</title>
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <h1>Source code for sintef</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Sintef</span>
<span class="sd">======</span>

<span class="sd">Evaluate initial bubble and droplet sizes from the SINTEF model</span>

<span class="sd">This module is deprecated and has been replaced by the `particle_size_models`</span>
<span class="sd">and `psf` modules.  In order to retain compatibility with previous versions, </span>
<span class="sd">we retain the original API of the `sintef` model, but replace all calculations</span>
<span class="sd">with calls to the appropriate functions in `particle_size_models` and `psf`.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="c1"># S. Socolofsky, September 2013, Texas A&amp;M University &lt;socolofs@tamu.edu&gt;.</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="p">(</span><span class="n">absolute_import</span><span class="p">,</span> <span class="n">division</span><span class="p">,</span> <span class="n">print_function</span><span class="p">)</span>

<span class="kn">from</span> <span class="nn">tamoc</span> <span class="kn">import</span> <span class="n">psf</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">copy</span> <span class="kn">import</span> <span class="n">copy</span>
<span class="kn">from</span> <span class="nn">scipy.optimize</span> <span class="kn">import</span> <span class="n">fsolve</span>

<div class="viewcode-block" id="modified_We_model"><a class="viewcode-back" href="../autodoc/sintef/sintef.modified_We_model.html#sintef.modified_We_model">[docs]</a><span class="k">def</span> <span class="nf">modified_We_model</span><span class="p">(</span><span class="n">D</span><span class="p">,</span> <span class="n">rho_gas</span><span class="p">,</span> <span class="n">m_gas</span><span class="p">,</span> <span class="n">mu_gas</span><span class="p">,</span> <span class="n">sigma_gas</span><span class="p">,</span> <span class="n">rho_oil</span><span class="p">,</span> <span class="n">m_oil</span><span class="p">,</span> 
                      <span class="n">mu_oil</span><span class="p">,</span> <span class="n">sigma_oil</span><span class="p">,</span> <span class="n">rho</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    This function is deprecated:  Use psf.sintef() instead.</span>
<span class="sd">    </span>
<span class="sd">    Compute the initial oil droplet and gas bubble sizes from the SINTEF model</span>
<span class="sd">    </span>
<span class="sd">    Apply the SINTEF modified Weber number model to estimate the initial </span>
<span class="sd">    oil and gas particle sizes.  This function calculates the adjusted exit</span>
<span class="sd">    velocity based on a void fraction and buoyancy adjustment per the method</span>
<span class="sd">    suggested by SINTEF.</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    D : float</span>
<span class="sd">        Diameter of the release point (m)</span>
<span class="sd">    rho_gas : float</span>
<span class="sd">        In-situ density of the gas (kg/m^3)</span>
<span class="sd">    m_gas : ndarray</span>
<span class="sd">        Array of mass fluxes for each component of the gas object (kg/s)</span>
<span class="sd">    mu_gas : float</span>
<span class="sd">        Dynamic viscosity of gas (Pa s)</span>
<span class="sd">    sigma_gas : float</span>
<span class="sd">        Interfacial tension between gas and seawater (N/m)</span>
<span class="sd">    rho_oil : float</span>
<span class="sd">        In-situ density of the oil</span>
<span class="sd">    m_oil : ndarray</span>
<span class="sd">        Array of mass fluxes for each component of the oil object (kg/s)</span>
<span class="sd">    mu_oil : float</span>
<span class="sd">        Dynamic viscosity of oil (Pa s)</span>
<span class="sd">    sigma_oil : float</span>
<span class="sd">        Interfacial tension between oil and seawater (N/m)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the continuous phase fluid (kg/m^3)</span>
<span class="sd">    </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    A tuple containing:</span>
<span class="sd">        de_gas : float</span>
<span class="sd">            The volume mean diameter of the gas bubbles (m)</span>
<span class="sd">        de_oil : float</span>
<span class="sd">            The volume mean diameter of the oil droplets (m)</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Make sure the masses are in arrays</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">m_gas</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">m_gas</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
            <span class="n">m_gas</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">m_gas</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">m_gas</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">m_gas</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">m_oil</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">m_oil</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
            <span class="n">m_oil</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">m_oil</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">m_oil</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">m_oil</span><span class="p">)</span>
    
    <span class="c1"># Call the psf functions</span>
    <span class="n">mu</span> <span class="o">=</span> <span class="mf">0.0012</span>   <span class="c1"># pass mu of seawater (not used)</span>
    <span class="n">de_gas</span><span class="p">,</span> <span class="n">de_max</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">alpha</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">sintef</span><span class="p">(</span><span class="n">D</span><span class="p">,</span> <span class="n">m_gas</span><span class="p">,</span> <span class="n">rho_gas</span><span class="p">,</span> <span class="n">m_oil</span><span class="p">,</span> <span class="n">rho_oil</span><span class="p">,</span> 
                                          <span class="n">mu_gas</span><span class="p">,</span> <span class="n">sigma_gas</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">,</span> 
                                          <span class="n">fp_type</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">use_d95</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
    
    <span class="n">de_oil</span><span class="p">,</span> <span class="n">de_max</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">alpha</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">sintef</span><span class="p">(</span><span class="n">D</span><span class="p">,</span> <span class="n">m_gas</span><span class="p">,</span> <span class="n">rho_gas</span><span class="p">,</span> <span class="n">m_oil</span><span class="p">,</span> <span class="n">rho_oil</span><span class="p">,</span> 
                                          <span class="n">mu_oil</span><span class="p">,</span> <span class="n">sigma_oil</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">mu</span><span class="p">,</span> 
                                          <span class="n">fp_type</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">use_d95</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
    
    <span class="c1"># Return the bubble and droplet sizes</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">de_gas</span><span class="p">,</span> <span class="n">de_oil</span><span class="p">)</span></div>


<span class="c1"># Provide tool to estimate the maximum stable particle size</span>
<div class="viewcode-block" id="de_max"><a class="viewcode-back" href="../autodoc/sintef/sintef.de_max.html#sintef.de_max">[docs]</a><span class="k">def</span> <span class="nf">de_max</span><span class="p">(</span><span class="n">sigma</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">rho</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    This function is deprecated:  Use psf.de_max_oil() instead.</span>
<span class="sd">    </span>
<span class="sd">    Calculate the maximum stable particle size</span>
<span class="sd">    </span>
<span class="sd">    Predicts the maximum stable particle size per Clift et al. (1978) via </span>
<span class="sd">    the equation:</span>
<span class="sd">    </span>
<span class="sd">    d_max = 4. * np.sqrt(sigma / (g (rho - rho_p)))</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    sigma : float</span>
<span class="sd">        Interfacial tension between the phase undergoing breakup and the </span>
<span class="sd">        ambient receiving continuous phase (N/m)</span>
<span class="sd">    rho_p : float</span>
<span class="sd">        Density of the phase undergoing breakup (kg/m^3)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the ambient receiving continuous phase (kg/m^3) </span>
<span class="sd">    </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    d_max : float</span>
<span class="sd">        Maximum stable particle size (m)</span>
<span class="sd">    </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="n">psf</span><span class="o">.</span><span class="n">de_max_oil</span><span class="p">(</span><span class="n">rho_p</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">rho</span><span class="p">)</span></div>

<div class="viewcode-block" id="de_50"><a class="viewcode-back" href="../autodoc/sintef/sintef.de_50.html#sintef.de_50">[docs]</a><span class="k">def</span> <span class="nf">de_50</span><span class="p">(</span><span class="n">U</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">mu_p</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">rho</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    This function is deprecated:  Use psf.sintef_d50() instead.</span>
<span class="sd">    </span>
<span class="sd">    Predict the volume mean diameter from a modified Weber number model</span>
<span class="sd">    </span>
<span class="sd">    Calculates the SINTEF modified Weber number model for the volume mean </span>
<span class="sd">    diameter of a blowout release.</span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    U : float</span>
<span class="sd">        Effective exit velocity after void fraction and buoyancy correction </span>
<span class="sd">        of the phase undergoing breakup (m/s)</span>
<span class="sd">    D : float</span>
<span class="sd">        Diameter of the discharge (m)</span>
<span class="sd">    rho_p : float</span>
<span class="sd">        Density of the phase undergoing breakup (kg/m^3)</span>
<span class="sd">    mu_p : float</span>
<span class="sd">        Dynamic viscosity of the phase undergoing breakup (Pa s)</span>
<span class="sd">    sigma : float</span>
<span class="sd">        Interfacial tension between the phase undergoing breakup and the </span>
<span class="sd">        ambient receiving continuous phase (N/m)</span>
<span class="sd">    </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    de_50 : float</span>
<span class="sd">        The volume mean diameter of the phase undergoing breakup</span>
<span class="sd">    </span>
<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    This function first checks the We number.  If the We is less than the </span>
<span class="sd">    critical value of 350 required for atomization, then the fluid particle </span>
<span class="sd">    diameter is estimated as 1.2 D.  Otherwise, the SINTEF modified We number </span>
<span class="sd">    model is used.  In both cases, the resulting particle diameter is compared</span>
<span class="sd">    to the maximum stable particle size per Clif et al. (1978) of </span>
<span class="sd">        </span>
<span class="sd">        d_max = 4 (sigma/ (g (rho - rho_p)))^(1/2).  </span>
<span class="sd">        </span>
<span class="sd">    The function returns the lesser of the estimated particle size or the </span>
<span class="sd">    maximum stable particle size.</span>
<span class="sd">    </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Call the psf function</span>
    <span class="n">de</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">sintef_d50</span><span class="p">(</span><span class="n">U</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">mu_p</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">rho</span><span class="p">)</span>
    
    <span class="c1"># Require the diameter to be less than the maximum stable size</span>
    <span class="n">dmax</span> <span class="o">=</span> <span class="n">de_max</span><span class="p">(</span><span class="n">sigma</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">rho</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">de</span> <span class="o">&gt;</span> <span class="n">dmax</span><span class="p">:</span>
        <span class="n">de</span> <span class="o">=</span> <span class="n">dmax</span>
    
    <span class="c1"># Return the result</span>
    <span class="k">return</span> <span class="n">de</span></div>

<div class="viewcode-block" id="rosin_rammler"><a class="viewcode-back" href="../autodoc/sintef/sintef.rosin_rammler.html#sintef.rosin_rammler">[docs]</a><span class="k">def</span> <span class="nf">rosin_rammler</span><span class="p">(</span><span class="n">nbins</span><span class="p">,</span> <span class="n">d50</span><span class="p">,</span> <span class="n">md_total</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">rho</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    This function is deprecated:  Use psf.rosin_rammler() instead.</span>
<span class="sd">    </span>
<span class="sd">    Return the volume size distribution from the Rosin Rammler distribution</span>
<span class="sd">    </span>
<span class="sd">    Returns the fluid particle diameters in the selected number of bins on</span>
<span class="sd">    a volume basis from the Rosin Rammler distribution with parameters </span>
<span class="sd">    k = -ln(0.5) and alpha = 1.8.  </span>
<span class="sd">    </span>
<span class="sd">    Parameters</span>
<span class="sd">    ----------</span>
<span class="sd">    nbins : int</span>
<span class="sd">        Desired number of size bins in the particle volume size distribution</span>
<span class="sd">    d50 : float</span>
<span class="sd">        Volume mean particle diameter (m)</span>
<span class="sd">    md_total : float</span>
<span class="sd">        Total particle mass flux (kg/s)</span>
<span class="sd">    sigma : float</span>
<span class="sd">        Interfacial tension between the phase undergoing breakup and the </span>
<span class="sd">        ambient receiving continuous phase (N/m)</span>
<span class="sd">    rho_p : float</span>
<span class="sd">        Density of the phase undergoing breakup (kg/m^3)</span>
<span class="sd">    rho : float</span>
<span class="sd">        Density of the ambient receiving continuous phase (kg/m^3) </span>
<span class="sd">    </span>
<span class="sd">    Returns</span>
<span class="sd">    -------</span>
<span class="sd">    de : ndarray</span>
<span class="sd">        Array of particle sizes at the center of each bin in the distribution</span>
<span class="sd">        (m)</span>
<span class="sd">    md : ndarray</span>
<span class="sd">        Total mass flux of particles corresponding to each bin (kg/s)</span>
<span class="sd">    </span>
<span class="sd">    Notes</span>
<span class="sd">    -----</span>
<span class="sd">    This method computes the un-truncated volume size distribution from the</span>
<span class="sd">    Rosin-Rammler distribution and then enforces that all particle sizes</span>
<span class="sd">    be less than the maximum stable size by moving mass in larger sizes to </span>
<span class="sd">    the maximum stable size bin.  </span>
<span class="sd">    </span>
<span class="sd">    References</span>
<span class="sd">    ----------</span>
<span class="sd">    Johansen, Brandvik, and Farooq (2013), &quot;Droplet breakup in subsea oil</span>
<span class="sd">    releases - Part 2: Predictions of droplet size distributions with and </span>
<span class="sd">    without injection of chemical dispersants.&quot; Marine Pollution Bulletin,</span>
<span class="sd">    73: 327-335.  doi:10.1016/j.marpolbul.2013.04.012.</span>
<span class="sd">    </span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c1"># Get the maximum stable size</span>
    <span class="n">dmax</span> <span class="o">=</span> <span class="n">de_max</span><span class="p">(</span><span class="n">sigma</span><span class="p">,</span> <span class="n">rho_p</span><span class="p">,</span> <span class="n">rho</span><span class="p">)</span>
    
    <span class="c1"># Define the parameters of the distribution</span>
    <span class="n">k</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span>
    <span class="n">alpha</span> <span class="o">=</span> <span class="mf">1.8</span>
    
    <span class="n">de</span><span class="p">,</span> <span class="n">V_frac</span> <span class="o">=</span> <span class="n">psf</span><span class="o">.</span><span class="n">rosin_rammler</span><span class="p">(</span><span class="n">nbins</span><span class="p">,</span> <span class="n">d50</span><span class="p">,</span> <span class="n">k</span><span class="p">,</span> <span class="n">alpha</span><span class="p">)</span>
    
    <span class="c1"># Compute the mass fraction for each diameter</span>
    <span class="n">md</span> <span class="o">=</span> <span class="n">V_frac</span> <span class="o">*</span> <span class="n">md_total</span>
    
    <span class="c1"># Truncate the distribution at the maximum stable droplet size</span>
    <span class="n">imax</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">de</span><span class="p">)):</span>
        <span class="k">if</span> <span class="n">de</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">&gt;</span> <span class="n">dmax</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">imax</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">imax</span> <span class="o">=</span> <span class="n">i</span>
                <span class="n">de</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">dmax</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">md</span><span class="p">[</span><span class="n">imax</span><span class="p">]</span> <span class="o">+=</span> <span class="n">md</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
                <span class="n">md</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0.</span>
    
    <span class="c1"># Return the particle size distribution</span>
    <span class="k">return</span> <span class="p">(</span><span class="n">de</span><span class="p">,</span> <span class="n">md</span><span class="p">)</span></div>

</pre></div>

          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../index.html">Texas A&M Oil spill / Outfall Calculator</a></h1>








<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../user_manual.html">TAMOC User Manual</a></li>
<li class="toctree-l1"><a class="reference internal" href="../unit_tests.html">Unit Tests</a></li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../readme.html">Read Me File</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="index.html">Module code</a><ul>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2020, Scott A. Socolofsky.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 2.4.4</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
    </div>

    

    
  </body>
</html>